<?php
session_start();
include_once("function_right.php");
if(!JudgeUserRight()) return FALSE;
?>
<?php
include_once "function_sys_time.php";
include_once "function_misc_log.php";

if ($_POST['settype'] == 1) // menu
{
	$in_array['year'] = $_POST['sel_year'];
	$in_array['month'] = $_POST['sel_mon'];
	$in_array['hour'] = $_POST['sel_hour'];
	$in_array['min'] = $_POST['sel_min'];
	$in_array['sec'] = $_POST['sel_sec'];

	if ( checkdate($in_array['month'],31,  $in_array['year']) )
		$in_array['day'] = $_POST['sel_day31'];
	else if ( checkdate($in_array['month'],30, $in_array['year']) )
		$in_array['day'] = $_POST['sel_day30'];
	else if ( checkdate($in_array['month'],29, $in_array['year']) )
		$in_array['day'] = $_POST['sel_day29'];
	else if ( checkdate($in_array['month'],28, $in_array['year']) )
		$in_array['day'] = $_POST['sel_day28'];

	SetSystemTimeByMenu($in_array);
	logger("Modify", $in_array, "Sys_Time");
}
else if ($_POST['settype'] == 0) // net
{
	$in_array['ServerAddress'] = $_POST['dev'];
	$in_array['Enabled'] = $_POST['enabled'];
	$net = new CNetTime();
	$net ->EditItem($in_array);
	logger("Modify", $in_array, "Sys_Time");
}
else if ($_POST['settype'] == 3) // sync: 
{
	$in_array['year'] = $_POST['sel_year2'];
	$in_array['month'] = $_POST['sel_mon2']  ;
	$in_array['hour'] = $_POST['sel_hour2'];
	$in_array['min'] = $_POST['sel_min2'];
	$in_array['sec'] = $_POST['sel_sec2'];
	$in_array['day'] = $_POST['sel_day2'];

	SetSystemTimeByMenu($in_array);
	logger("Modify", $in_array, "Sys_Time");
}

echo("<meta http-equiv='refresh'content=0;URL='sys_time_config.php'>");

?>
